const { ADD_NUMBER, CHANGE_NAME } = require("./constants")

const initialState = {
  name: "jay",
  counter: 100
}

function reducer(state = initialState, action) {
  switch (action.type) {
    case CHANGE_NAME:
      return { ...state, name:action.nam } 

    case ADD_NUMBER:
      return { ...state, counter: state.counter + action.num}
    default:
      return state
  }
}

module.exports = reducer